package com.ssextjs.component.grid;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ColumnModel {
	public int allcolwidth=0;
	public List colums;
	public List columsWidth;
	public ColumnModel(List cols) {
		colums = cols;
		Iterator it = cols.iterator();
		while (it.hasNext()) {
			Column col = (Column) it.next();
			allcolwidth+=col.getWidth();
		}
		columsWidth = new ArrayList();
		it = colums.iterator();
		while (it.hasNext()) {
			Column col = (Column) it.next();
			int width = (int) Math.round((double)col.getWidth()/(double)allcolwidth*100);
			columsWidth.add(width+"%"); 
		}
	}
	
	public List getColums() {
		return this.colums;
	}
	
	public int getAllWidth() {
		return this.allcolwidth;
	}
	
	public String getFitWidth(int colIndex) {
		return (String) columsWidth.get(colIndex);
	}
	
}
